<script type="text/javascript" src="<?php echo base_url() . SKINSPATH; ?>js/jquery.timepicker/jquery-ui-timepicker-addon.js"></script>
<link rel="stylesheet" href="<?php echo base_url() . SKINSPATH; ?>js/jquery.timepicker/jquery-ui-timepicker-addon.css" type="text/css"/>
<div class="content-box">
    <div class="box-header clear">
        <h2><?php echo lang('pg_edit_termination') ?></h2>
    </div>
    <div class="box-body clear">
        <?php echo validation_errors(); ?>
            <?php echo form_open(base_url().'termination/edit/'.$termination->id); ?>
            <div class="form-field clear">
            <label class="form-label fl-space2"><?php echo lang('lbl_category') ?> :</label>
            <select name="category_id" id="category_id" onchange="getProduct();">
            	<option value=""><?php echo lang('lbl_select_category') ?></option>
            <?php 
            foreach($categorys as $item){
				echo "<option value='".$item->id."' ".($termination->category_id == $item->id ? 'selected="selected"':"").">".$item->category_name."</option>";
			}
            ?>
            </select>
        </div>
        <div class="form-field clear">
            <label class="form-label fl-space2"><?php echo lang('lbl_provider') ?> :</label>
            <select name="provider_id" id="provider_id" onchange="getProduct();">
            	<option value=""><?php echo lang('lbl_select_provider') ?></option>
            <?php 
            foreach($providers as $item){
				echo "<option value='".$item->id."' ".($termination->provider_id == $item->id ? 'selected="selected"':"").">".$item->provider_name."</option>";
			}
            ?>
            </select>
        </div>
        <div class="form-field clear">
            <label class="form-label fl-space2"><?php echo lang('lbl_product') ?> :</label>
            <select name="product_id" id="product_id">
            	<option value=""><?php echo lang('lbl_select_product') ?></option>
            	<?php 
            foreach($products as $item){
				echo "<option value='".$item->id."' ".($termination->product_id == $item->id ? 'selected="selected"':"").">".$item->product_name."</option>";
			}
            ?>
            </select>
        </div>
            <div class="form-field clear">
            <label class="form-label fl-space2"><?php echo lang('lbl_member') ?> :</label>
            <select name="member_id" id="member_id" onchange="getContract();">
            	<option value=""><?php echo lang('lbl_select_member') ?></option>
	            <?php 
	            foreach($members as $item){
					echo "<option value='".$item->id."' ".($item->id == $termination->member_id ? "selected='selected'" : "").">".$item->first_name." ".$item->last_name."</option>";
				}
	            ?>
            </select>
        </div>
        <div class="form-field clear">
            <label class="form-label fl-space2"><?php echo lang('lbl_contract') ?> :</label>
            <input type="text" value="<?php echo set_value('contract_number',$termination->contract_number); ?>" name="contract_number" id="contract_number" class="text" maxlength="10" />
        </div>
        	<div class="form-field clear">
	            <label class="form-label fl-space2"><?php echo lang('lbl_status') ?> :</label>
	            <?php echo form_dropdown('status', $status, $termination->status); ?>
	        </div>
            <div class="form_submit">
                <input type="submit" class="submit" value="<?php echo lang('btn_save') ?>" id="save" name="save">
                <input onclick='location.href="<?php echo base_url() ?>termination"' type="button" class="submit" value="<?php echo lang('btn_cancel') ?>" name="cancel">
            </div>
        <?php echo form_close();?>
    </div>
</div>
<script type="text/javascript">
function getProduct(){
	if($('#category_id').val() && $('#provider_id').val()){
		$.ajax({
            type: "POST",
            url: "<?php echo base_url() ?>contract/getproduct",
            data: "category_id=" + $('#category_id').val() + "&provider_id=" + $('#provider_id').val(),
            success: function(result) {
            	$('#product_id').html( result );
            }
        })
	}
}
</script>